<template>
	<view class="index">
		<headSearch></headSearch>
		<view class="loading" v-if="loading"><i class="fa fa-spin fa-spinner"></i>
			小豆正在努力奔跑中~
		</view>
		<movieBody :movieListData="movieListData" v-if="!loading"></movieBody>
	</view>
</template>

<script>
	import movieBody from '../../components/movieBody/movieBody.vue';
	import headSearch from '../../components/headSearch/headSearch.vue';
	export default {
		data() {
			return {
				loading: true,
				movieListData: [{
					title: "热播",
					url: "/pages/more/more?type=热播",
					movieListInfo: []
				}, {
					title: "即将上映",
					url: "/pages/more/more?type=即将上映",
					movieListInfo: []
				}, {
					title: "好评电影",
					url: "",
					movieListInfo: []
				}]
			}
		},
		onLoad() {
			this.getmovieListData()
		},
		methods: {
			getmovieListData() {
				this.$api.getmovieListData((res) => {
					if (res.code) {
						this.loading = false;
						this.movieListData[0].movieListInfo = res.hotMovie;
						this.movieListData[1].movieListInfo = res.soonMovie;
						this.movieListData[2].movieListInfo = res.topMovie;
					}
				})
			}
		},
		components: {
			movieBody,
			headSearch
		}
	}
</script>

<style lang="scss">
	.loading {
		width: 100vw;
		height: 100vh;
		position: fixed;
		top: 94upx;
		left: 0;
		z-index: 5;
		background-color: rgba(255, 255, 255, 0.85);
		line-height: 70vh;
		text-align: center;
		font-size: 1.5rem;
		color: #a2a2a2;
	}
</style>
